<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <title>java</title>
    <link rel="stylesheet" th:href="@{/css/style.css}" />
</head>
<body>
<div class="n-support">请使用Chrome、Safari等webkit内核的浏览器！</div>
<div class="n-head">
    <div class="g-doc f-cb">
        <div class="user" th:if="${session.user == null}">请<a th:href="@{/login}">[登录]</a></div>
        <div class="user" th:if="${session.user != null && session.user.userType == 1}">
            卖家你好，<span class="name" th:text="${session.user.username}"></span>！<a th:href="@{/logout}">[退出]</a>
        </div>
        <div class="user" th:if="${session.user != null && session.user.userType == 2}">
            买家你好，<span class="name" th:text="${session.user.username}"></span>！<a th:href="@{/logout}">[退出]</a>
        </div>
        <ul class="nav">
            <li><a th:href="@{/}">首页</a></li>
            <li th:if="${session.user != null && session.user.userType == 1}"><a th:href="@{/public}">发布</a></li>
            <li th:if="${session.user != null && session.user.userType == 2}"><a th:href="@{/account}">账务</a></li>
            <li th:if="${session.user != null && session.user.userType == 2}"><a th:href="@{/settleAccount}">购物车</a></li>
        </ul>
    </div>
</div>
<div class="g-doc">
    <div class="m-tab m-tab-fw m-tab-simple f-cb">
        <h2 th:text="${commodity != null?'内容编辑':'内容发布'}"></h2>
    </div>
    <div class="n-public">
        <form
                th:if="${commodity != null}"
                class="m-form m-form-ht"
                id="form"
                method="post"
                th:action="@{/}+'editSubmit?id='+${commodity.id}"
                onsubmit="return false;"
                autocomplete="off"
        >
            <div class="fmitem">
                <label class="fmlab">标题：</label>
                <div class="fmipt">
                    <input type="hidden" name="id" th:value="${commodity.id}"/>
                    <input
                            class="u-ipt ipt"
                            name="title"
                            placeholder="2-80字符"
                            th:value="${commodity.title}"
                    />
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">摘要：</label>
                <div class="fmipt">
                    <input class="u-ipt ipt" name="summary" placeholder="2-140字符"
                           th:value="${commodity.summary}"/>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">图片：</label>
                <div class="fmipt" id="uploadType">
                    <input name="pic" type="radio" value="url" checked /> 图片地址
                    <input name="pic" type="radio" value="file" /> 本地上传
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab"></label>
                <div class="fmipt" id="urlUpload">
                    <input class="u-ipt ipt" name="image" placeholder="图片地址" th:value="${commodity.pic}"/>
                </div>
                <div class="fmipt" id="fileUpload" style="display: none">
                    <input class="u-ipt ipt" name="file" type="file" id="fileUp" />
                    <button class="u-btn u-btn-primary" id="upload">上传</button>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">正文：</label>
                <div class="fmipt">
              <textarea
                      class="u-ipt"
                      name="detail"
                      rows="10"
                      placeholder="2-1000个字符"
              >[[${commodity.text}]]</textarea>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">价格：</label>
                <div class="fmipt">
                    <input class="u-ipt price" name="price" th:value="${commodity.price}"/>元
                </div>
            </div>
            <div class="fmitem fmitem-nolab fmitem-btn">
                <div class="fmipt">

                    <button type="submit" class="u-btn u-btn-primary u-btn-lg" >
                        保 存
                    </button>
                </div>
            </div>
        </form>
        <form class="m-form m-form-ht" id="form" method="post" th:action="@{/publicSubmit}" onsubmit="return false;" autocomplete="off"
        th:if="${commodity == null}">
            <div class="fmitem">
                <label class="fmlab">标题：</label>
                <div class="fmipt">
                    <input class="u-ipt ipt" name="title" autofocus placeholder="2-80字符"/>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">摘要：</label>
                <div class="fmipt">
                    <input class="u-ipt ipt" name="summary" placeholder="2-140字符"/>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">图片：</label>
                <div class="fmipt" id="uploadType">
                    <input name="pic" type="radio" value="url" checked /> 图片地址
                    <input name="pic" type="radio" value="file" /> 本地上传
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab"></label>
                <div class="fmipt" id="urlUpload">
                    <input class="u-ipt ipt"  name="image" placeholder="图片地址"/>
                </div>
                <div class="fmipt" id="fileUpload"  style="display:none">
                    <input class="u-ipt ipt" name="file" type="file" id="fileUp"/>
                    <button class="u-btn u-btn-primary" id="upload">上传</button>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">正文：</label>
                <div class="fmipt">
                    <textarea class="u-ipt" name="detail" rows="10" placeholder="2-1000个字符"></textarea>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">价格：</label>
                <div class="fmipt">
                    <input class="u-ipt price" name="price"/>元
                </div>
            </div>
            <div class="fmitem fmitem-nolab fmitem-btn">
                <div class="fmipt">
                    <button type="submit" class="u-btn u-btn-primary u-btn-lg">发 布</button>
                </div>
            </div>
        </form>
        <span class="imgpre"><img th:src="${commodity==null?'':commodity.pic}" alt="" id="imgpre" /></span>
    </div>
</div>
<div class="n-foot">
    <p>
        版权所有：网易云课堂<a
            href="http://mooc.study.163.com/smartSpec/detail/85002.htm"
    >Java开发工程师(Web方向)</a
    >微专业团队
    </p>
</div>
<script type="text/javascript" th:src="@{/js/global.js}"></script>
<script type="text/javascript" th:src="@{/js/public.js}"></script>
</body>
</html>
